@extends('common.admin-master')
@section('html-header')
    <link rel="stylesheet" type="text/css" href="{{url('/css/admin/common.css')}}">
@endsection

@section('html-body')
    <div class="content">
        <div class="header">
            <h3 class="page-title">修改系统信息</h3>
        </div>
        <div class="container-fluid">
            <div class="row-fluid">
                <div class="well">
                    <div id="myTabContent" class="tab-content">
                        <div class="tab-pane active in" id="home" style="margin-left: 10%">
                            <ul class="fansinfo" style="list-style: none">
                                <form id="setsysinfo">
                                <li><em>网站名称：</em><span><input type="text" id="sitename" name="sitename" value="{{$sysinfo->sitename}}"/></span></li>
                                <li><em>keyworks：</em><span><input type="text" id="keyword" name="keyword" value="{{$sysinfo->keyword}}"/></span></li>
                                <li><em>description：</em><span><input type="text" id="description" name="description" value="{{$sysinfo->description}}"/></span></li>
                                <li><em>网站备案号：</em><span><input type="text" id="beian" name="beian" value="{{$sysinfo->beian}}"/></span></li>
                                <li><em>公司名称：</em><span><input type="text" id="company" name="company" value="{{$sysinfo->companyname}}"/></span></li>
                                <li><em>注册欢迎语：</em><span><input type="text" id="modemsg" name="modemsg" value="{{$sysinfo->modemsg}}"/></span></li>
                                </form>
                            </ul>
                            <div style="margin-left: 80px;margin-top: 20px">
                                    <button class="btn btn-primary save"><i class="icon-ok"></i>设置</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        jQuery(function() {
            var doc = document,
                    $doc = $(doc);

            function toggle() {
                $(".pop").toggle();
                $(".mirror").toggle();
            }

            $doc.on("click", ".eventBtn", function() {
                toggle();
            });

            $doc.on("click", ".mirror", function() {
                toggle();
            });

            $doc.on("click", ".pop button", function() {
                toggle();
            });

            jQuery.ajaxSetup({
                case:false,
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });

            $doc.on('click','.save',function(){
                $.ajax({
                    type:"post",
                    url:"{{route('Api.Admin.setSysInfo')}}",
                    dataType:"json",
                    data:$('#setsysinfo').serialize(),
                    success:function(obj){
                        if(obj.level === "success"){
                            noty({text:obj.message,type:obj.level,timeout:800,
                                callback:{
                                    afterClose:function(){
                                        location.reload();
                                    }
                                }
                            });
                        }
                    },
                    error:function(obj){
                        var datajson = obj.responseJSON;
                        noty({text:datajson.message,type:datajson.level,timeout:800});
                    }
                });
            });
        });
    </script>
@endsection